<template>
  <div class="test">
    <bscroll>
      <div>
        <ul>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
        <li>内容</li>
      </ul>
      <goods-list :goods="goods[currentType].list"></goods-list> 
      </div>
    </bscroll>
  </div>
</template>

<script>
import { getHomeMultidata, getHomeGoodsData, getshow } from "@/network/home.js";

import categoryNavBar from "./categoryNavBar.vue";
import Bscroll from "@/components/common/bscorll/Bscroll.vue";
import GoodsList from "@/components/context/goods/GoodsList";
export default {
  name: "Category",
  components: { categoryNavBar ,Bscroll,GoodsList},
  data() {
    return {
     currentType: "pop", //默认展示的pop数据
      goods: {
        pop: {
          page: 0,
          list: [],
        },
        new: {
          page: 0,
          list: [],
        },
        sell: {
          page: 0,
          list: [],
        },
      },
     
    };
  },
  created() {
    //初始加载分类的第一页数据
    this.getHomeGoodsData("pop");
  },
  methods: {
     getHomeGoodsData(type) {
      // 分类数据（自己的数据）
      console.log("查看当前页==", this.goods[type].page, this.currentType);
      const page = this.goods[type].page + 1;
      const psum = page * 10;
      getHomeGoodsData(type, psum).then((results) => {
        // result拿到的是一个数组对象
        this.goods[type].list.push(...results);
        // console.log("goods===", this.goods);
        this.goods[type].page = page;
      });
    },
  },
};
</script>

<style>

</style>